import React, { Component } from "react";

export default class App extends Component {
    state = {
        flag: true
    }
    render () {
        return (
            <div>
                <button onClick= { () => {
                    // 设置状态，参数是点击前的状态，属性
                    this.setState((prevState, props) => {
                        return {
                            flag: !prevState.flag
                        }
                    })
                }}>
                    切换
                </button>
                {
                    this.state.flag ? '😍喜欢' : '😠讨厌'
                }
            </div>
        )
    }
}